﻿package frEngine.multiThread.proxy
{
    import com.gengine.resource.mutiThread.*;
    import flash.utils.*;
    import frEngine.animateControler.particleControler.*;
    import frEngine.loaders.*;
    import frEngine.loaders.particleSub.*;

    public class ThreadParserParticle extends Object
    {
        public static const instance:ThreadParserParticle = new ThreadParserParticle;

        public function ThreadParserParticle()
        {
            return;
        }// end function

        public function doing(param1:Object) : void
        {
            var _bytes:ByteArray;
            var errorInfo:String;
            var voObj:* = param1;
            var particleParams:* = new ParticleParams(true);
            particleParams._useGpu = voObj.useGpu;
            particleParams.callBackId = voObj.callBackId;
            var particleParser:* = new ParticleParser(true);
            var data:* = voObj.data;
            var hasError:Boolean;
            if (data is ByteArray)
            {
                _bytes = ByteArray(data);
                _bytes.endian = Endian.LITTLE_ENDIAN;
                _bytes.position = 0;
                try
                {
                    data = _bytes.readObject();
                }
                catch (e:Error)
                {
                    hasError;
                }
            }
            if (!hasError)
            {
                errorInfo = particleParser.parser(particleParams, data);
                hasError = errorInfo != null;
            }
            if (!hasError)
            {
                particleParams.startBuild(this.parserComplete);
            }
            else
            {
                particleParams.parserSuccess = false;
                ThreadManager.instance.sendMessageToMain(particleParams, null, false);
            }
            return;
        }// end function

        private function parserComplete(param1:ParticleParams) : void
        {
            param1.parserSuccess = true;
            ThreadManager.instance.sendMessageToMain(param1, null, false);
            return;
        }// end function

        public static function replaceSourceUrl(param1:Object) : Boolean
        {
            var _loc_2:String = null;
            if (param1.particleType == EngineConstName.particleType2)
            {
                _loc_2 = param1.particleMesh;
            }
            if (param1.formation == EngineConstName.emitterShapeChoose6)
            {
                _loc_2 = param1.emitterShapeChoose;
            }
            if (param1.emitPlace == EmitterPosType.TextureRGB)
            {
                _loc_2 = param1.emitterTextureChoose;
            }
            return true;
        }// end function

    }
}
